package com.fingard.dsp.bank.reqrespobj.balancecheckconfirm;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.balancecheckconfirm.detail.RetAtsBalCheckConfirmDetail;
import com.fingard.xml.XmlTextWriter;

import java.util.HashMap;

public class RetAtsBalCheckConfirmQry extends RetAtsBase {

    public RetAtsBalCheckConfirmQry(ReqRespHeader p_header) {
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();//用于输出返回ATS的XML报文
    }

    private int writeRdCount = 0;

    public void writeRetDetail(RetAtsBalCheckConfirmDetail p_retDetail, boolean p_isBatch) throws Exception {
        writeRdCount++;
        if (writeRdCount == 1) {
            if (!hasWrittenRespCode) {
                writeRespCode("0");
            }
            if (!hasWrittenRespInfo) {
                writeRespInfo("");
            }
        }

        if (p_isBatch) {
            HashMap<String, String> nameMap = new HashMap<String, String>();
            nameMap.put("dzFlag", "DZFlag");
            this.writeToXmlDetailRecord(p_retDetail, nameMap, null);
        }else{
            retXmlWriter.writeElementString("RespCode", p_retDetail.respCode);
            retXmlWriter.writeElementString("RespInfo", p_retDetail.respInfo);
            retXmlWriter.writeElementString("ActNum", p_retDetail.actNum);
            retXmlWriter.writeElementString("ActName", p_retDetail.actName);
            retXmlWriter.writeElementString("BnkReqNo", p_retDetail.bnkReqNo);
            retXmlWriter.writeElementString("OprSeqNo", p_retDetail.oprSeqNo);
            retXmlWriter.writeElementString("OprAlias", p_retDetail.oprAlias);
            retXmlWriter.writeElementString("Result", p_retDetail.result);
            retXmlWriter.writeElementString("RetCode", p_retDetail.retCode);
            retXmlWriter.writeElementString("RetMsg", p_retDetail.retMsg);

            retXmlWriter.writeElementString("ISeqno", p_retDetail.iSeqno);
            retXmlWriter.writeElementString("StatementNumber", p_retDetail.statementNumber);
            retXmlWriter.writeElementString("DZFlag", p_retDetail.dzFlag);
            retXmlWriter.writeElementString("LoanNo", p_retDetail.loanNo);
        }
    }
}
